package ex.inte;

import java.text.ParseException;
import java.util.*;

/**
 * @author small瑞
 */
public class DateSortF{

    public static void main(String[] args) throws ParseException {

        final Random random = new Random();

        final Calendar calendar = Calendar.getInstance();

        final Date[] dates = new Date[5];

        MyDateTime myDateTime = new MyDateTime();
        Comparator<Date> comparator = new Comparator<Date>() {
            @Override
            public int compare(Date o1, Date o2) {
                return o1.compareTo(o2);
            }
        };
        for(int i = 0 , len = dates.length ; i < len ; i++){
            dates[i] = myDateTime.getDate();
            System.out.println(dates[i]);
        }
        System.out.println("-------------------------------------");
        System.out.println("自然排序后:");
        Arrays.sort(dates,comparator);
        for(int i = 0 , len = dates.length ; i < len ; i++){
            System.out.println(dates[i]);
        }
        System.out.println("-------------------------------------");
        System.out.println("倒序后:");
        Comparator<Date> comparator1 = (o1,o2) ->-o1.compareTo(o2);
        Arrays.sort(dates,comparator1);
        for(int i = 0 , len = dates.length ; i < len ; i++){
            System.out.println(dates[i]);
        }
    }

}
